package com.joe.codemother.core;

import com.joe.codemother.ai.model.HtmlCodeResult;
import com.joe.codemother.ai.model.MultiFileCodeResult;
import com.joe.codemother.core.file.HtmlFileSaveTemplate;
import com.joe.codemother.core.file.MultiFileSaveTemplate;
import com.joe.codemother.entity.enums.GenerateTypeEnum;

import java.io.File;

public class SaveFileExecutor {

    private static final HtmlFileSaveTemplate htmlFileSaveTemplate = new HtmlFileSaveTemplate();

    private static final MultiFileSaveTemplate multiFileSaveTemplate = new MultiFileSaveTemplate();

    public static File saveFile(Object result, GenerateTypeEnum generateType, Long appId) {
        switch (generateType) {
            case HTML: return htmlFileSaveTemplate.saveCode((HtmlCodeResult) result,appId);
            case MULTI_FILE: return multiFileSaveTemplate.saveCode((MultiFileCodeResult) result,appId);
            default: throw new IllegalArgumentException("Invalid GenerateType");
        }
    }

}
